const express = require("express")
const router = require("./router")
const bodyParser = require("body-parser")
const cors = require("cors")
// const fs = require('fs')
// const https = require('https')
const app = express()

app.use(express.static("upload-books"))
// const privateKey = fs.readFileSync('https/book_youbaobao_xyz.key', 'utf8')
// const certificate = fs.readFileSync('https/book_youbaobao_xyz.pem', 'utf8')
// const credentials = { key: privateKey, cert: certificate }
// const httpsServer = https.createServer(credentials, app)
// httpsServer.listen(SSLPORT, function() {
//   console.log('HTTPS Server is running on: https://localhost:%s', SSLPORT)
// })
app.use(cors())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.use("/", router)

const SSLPORT = 18082

const server = app.listen(SSLPORT, function () {
  const { address, port } = server.address()
  console.log("http服务启动成功：http://%s:%s", address, port)
})
